package com.zygh.questionnairesurvey.controller;

import com.zygh.questionnairesurvey.server.ExportExcelService;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @program: questionnaire-survey
 * @description: 导出Excel
 * @author: ID-Tang
 * @create: 2021-05-11 16:28
 **/
@RestController
@RequestMapping(value = "/export-excel")
@Api(tags = "导出excel")
public class ExportExcelController {
    @Resource
    ExportExcelService exportExcelService;

    @RequestMapping(value = "/export", method = RequestMethod.GET)
    @ApiOperation(value = "导出excel")
    @ApiImplicitParam(name = "state", value = "1:已填写警员   2:未填写警员  3:已填写有问题  4:已填写无问题")
    public Object export(HttpServletResponse response, Integer state,
                         @RequestParam(required = false) Integer deptId,
                         @ApiParam(name = "termStatus", value = "是否为领导班子（0：民警  1：领导班子 2：工勤人员）")
                         @RequestParam(required = false) Integer termStatus) throws IOException {
        return exportExcelService.export(response, state, deptId, termStatus);
    }


    @GetMapping(value = "/exprot")
    @ApiOperation(value = "导出问题统计报表")
    @ApiImplicitParam(name = "id", value = "部门id")
    public Object export(HttpServletResponse response, Integer id) throws IOException {
        return exportExcelService.exprot(response, id);
    }

    @GetMapping(value = "/exprotAll")
    @ApiOperation(value = "导出民警+工勤人员问题统计报表")
    @ApiImplicitParam(name = "id", value = "部门id")
    public Object exprotAll(HttpServletResponse response, Integer id) throws IOException {
        return exportExcelService.exprotAll(response, id);
    }


    @GetMapping(value = "/worker")
    @ApiOperation(value = "导出工勤人员问题统计报表")
    public Object worker(HttpServletResponse response,Integer id) throws IOException {
        return exportExcelService.worker(response,id);
    }


    @RequestMapping(value = "/exportByLowest", method = RequestMethod.GET)
    @ApiOperation(value = "通过问题id导出人员信息")
    public Object exportByLowest(HttpServletResponse response,
                                 @ApiParam(name = "lowest", value = "问题id", required = true)
                                 @RequestParam Integer lowest,
                                 @ApiParam(name = "termStatus", value = "不为3：民警、领导班子   3：工勤人员）")
                                 @RequestParam(required = false) Integer termStatus,
                                 @ApiParam(name = "deptId", value = "大队id")
                                 @RequestParam(required = false) Integer deptId) {
        return exportExcelService.exportByLowest(response, lowest, termStatus, deptId);
    }

    @GetMapping(value = "/exportUser")
    @ApiOperation(value = "根据部门导出人员信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "部门id", dataType = "Integer"),
            @ApiImplicitParam(name = "termStatus", value = "用户类型（0：民警  1：领导班子   3：工勤人员）", dataType = "Integer")

    })
    public Object exportUser(HttpServletResponse response, Integer id, Integer termStatus) throws IOException {
        return exportExcelService.exportUser(response, id, termStatus);
    }


    @GetMapping(value = "/exportProblem")
    @ApiOperation(value = "根据部门导出单位问题")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "部门id", dataType = "Integer", required = true),
            @ApiImplicitParam(name = "problemId", value = "问题最低一级id", dataType = "Integer"),
    })
    public Object exportProblem(HttpServletResponse response, Integer id, String encoder, Integer termStatus,String warningsignal, String name) throws IOException {
        return exportExcelService.exportProblem(response, id, encoder, termStatus,warningsignal, name);
    }

    @GetMapping(value = "/findDetailStaticeById")
    @ApiOperation(value = "根据部门id导出问题统计人员信息")
    public Object findDetailStaticeById(HttpServletResponse response, Integer id, Integer termStatus) throws IOException {
        return exportExcelService.findDetailStaticeById(response, id, termStatus);
    }

}
